package com.mj;

import com.mj.file.FileInfo;
import com.mj.file.Files;
import com.mj.map.Map;
import com.mj.map.TreeMap;
import com.mj.set.Set;
import com.mj.set.TreeSet;

public class Main {
    static void test01() {
        TreeMap<String, Integer> map = new TreeMap<>();
        map.put("c", 2);
        map.put("a", 8);
        map.put("b", 6);
        map.put("c", 4);

        map.traveresal(new Map.Visitor<String, Integer>() {
            @Override
            public boolean visit(String key, Integer value) {
                System.out.println(key + "_" + value);
                return false;
            }
        });
    }

    static void test02() {
        FileInfo fileInfo = Files.read("D:\\idea-workspace\\algorithm\\09-集合\\src", new String[]{"java"});
        System.out.println("文件数量：" + fileInfo.getFiles());
        System.out.println("代码行数：" + fileInfo.getLines());
        System.out.println("单词数量：" + fileInfo.words().length);
        String[] words = fileInfo.words();

        TreeMap<String, Integer> map = new TreeMap<>();

        for (int i = 0; i < words.length; i++) {
            Integer count = map.get(words[i]);
            count = count == null ? 1 :count+1;
            map.put(words[i],count);
        }
        System.out.println(map.size());
                map.traveresal(new Map.Visitor<String, Integer>() {
            @Override
            public boolean visit(String key, Integer value) {
                System.out.println(key + "_" + value);
                return false;
            }
        });
    }

     static void test03() {
        Set<String> set = new TreeSet<>();
        set.add("c");
        set.add("a");
        set.add("b");
        set.add("c");

        set.traversal(new Set.Visitor<String>() {
            @Override
            public boolean visit(String key) {
                System.out.println(key );
                return false;
            }
        });
    }

    public static void main(String[] args) {
//        test03();
        //浮点数转为整数（哈希值）
        int bits = Float.floatToIntBits(10.6f);
        System.out.println(bits);
        //浮点数转为整数之后，转为二进制数
        System.out.println( Integer.toBinaryString(bits));
    }
}
